package com.woniu.hystrix;

import com.woniu.api.RemoteProductServe;
import com.woniu.entity.Product;
import com.woniu.entity.ProductDTO;
import com.woniu.entity.utils.ResponseEntity;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Author WY
 * @PackageName phase-iv-cyx
 * @Package com.woniu.hystrix
 * @Date 2022/12/7 17:10
 * @Version 1.0
 */
@Component
public class FallbackFactoryCommand implements FallbackFactory<RemoteProductServe> {
    @Override
    public RemoteProductServe create(Throwable throwable) {
        return new RemoteProductServe() {
            @Override
            public ResponseEntity findOneByPid(Integer pid) {
                return ResponseEntity.TIMEOUT;
            }

            @Override
            public ResponseEntity updateProduct(Product product) {
                return ResponseEntity.TIMEOUT;
            }

            @Override
            public ResponseEntity findAllByNameOrPrice1(ProductDTO productDTO) {
                return ResponseEntity.TIMEOUT;
            }
        };
    }
}
